<template>
    <view>
        <view class="cu-card article" @tap="Detail" data-type="thing" :data-val="oneThing.Id" v-for="(oneThing, index) in thingList" :key="index">
            <view class="cu-item shadow">
                <view class="title">
                    <view class="text-cut">
                        {{ oneThing.title }}
                        <view class="cu-tag bg-gray light sm round" v-if="oneThing.complete === 1">已认领</view>
                        <view class="cu-tag bg-green light sm round" v-if="oneThing.complete === 0">未认领</view>
                        <view class="cu-tag bg-yellow light sm round" v-if="oneThing.hasReward === 1">要报酬</view>
                    </view>
                </view>
                <view class="content">
                    <image v-if="oneThing.hasImg === 1" :src="oneThing.ImgUrl" mode="aspectFill"></image>
                    <view class="desc">
                        <view class="text-content">{{ oneThing.content === '' ? '它没有编辑详情内容哦' : oneThing.content }}</view>
                        <view>
                            <view class="cu-tag bg-red light sm round" v-for="(tag, index1) in oneThing.tags" :key="index1">{{ tag }}</view>
                        </view>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
// pages/mything/mything.js
const app = getApp();
export default {
    data() {
        return {
            thingList: '',

            oneThing: {
                Id: '',
                complete: 0,
                hasReward: 0,
                hasImg: 0,
                ImgUrl: '',
                content: '',
                tags: []
            },

            tag: ''
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: function (options) {
        this.getData()
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
		this.getData();
    },
    methods: {
		
		getData:function(e){
			uni.showLoading({
				title: '加载中...'
			});
			let that = this;
			uni.request({
				url: app.globalData.ApiUrl + 'api/Android/thingList',
			
				//这里填写你的接口路径
				header: {
					'Content-Type': 'application/json'
				},
			
				data: {
					SafeCode: uni.getStorageSync('SafeCode')
				},
			
				method: 'POST',
			
				success: function (res) {
					that.setData({
						thingList: res.data
					});
					uni.hideLoading();
				}
			});
			uni.stopPullDownRefresh();	
		},
		
        Detail: function (e) {
            var type = e.currentTarget.dataset.type;
            var val = e.currentTarget.dataset.val;
            uni.navigateTo({
                url: '../detail/detail?type=' + type + '&id=' + val
            });
        }
    }
};
</script>
<style>
@import './mything.css';
</style>
